﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Web.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            BindNews();
            BindShops();
            BindAbout();
            BindTopList();
            BindOpus();
            BindStylist();
            return View();
        }

        /// <summary>
        /// 绑定行业新闻
        /// </summary>
        private void BindNews()
        {
            Manager.BLL.Admin.M_NewsBll bllNews = new Manager.BLL.Admin.M_NewsBll();
            IList<Manager.Model.Admin.M_News> news= bllNews.GetModelList("IsValid=1 Order By NewsID Desc");
            ViewBag.NewsList = news.Take(5);
        }
        /// <summary>
        /// 绑定名店推荐
        /// </summary>
        private void BindShops()
        {
            Manager.BLL.Admin.M_ShopBll bllShop = new Manager.BLL.Admin.M_ShopBll();
            IList<Manager.Model.Admin.M_Shop> shops = bllShop.GetModelList("IsValid=1 Order By ShopId Desc");
            ViewBag.ShopList = shops.Take(5);
        }
        /// <summary>
        /// 精品活动
        /// </summary>
        private void BindAbout()
        {
            Manager.BLL.Admin.M_AboutBll bllAbout = new Manager.BLL.Admin.M_AboutBll();
            IList<Manager.Model.Admin.M_About> abouts = bllAbout.GetModelList("IsValid=1 Order By AboutID Desc");
            ViewBag.AboutList = abouts.Take(5);
        }

        /// <summary>
        /// 首页固顶
        /// </summary>
        private void BindTopList()
        {
            Manager.BLL.Admin.M_ProductBll bllProduct = new Manager.BLL.Admin.M_ProductBll();
            IList<Manager.Model.Admin.M_Product> products = bllProduct.GetModelList("IsValid=1 And IsTop=1 Order By ProductID");
            ViewBag.ProductList = products.Take(5).ToList<Manager.Model.Admin.M_Product>();
        }
        /// <summary>
        /// 名设计师
        /// </summary>
        private void BindStylist()
        {
            Manager.BLL.Admin.M_StylistBll bllStylist = new Manager.BLL.Admin.M_StylistBll();
            IList<Manager.Model.Admin.M_Stylist> stylists = bllStylist.GetModelList("IsValid=1 And IsTop=1 Order By StylistID");
            ViewBag.StylistList = stylists.Take(5).ToList<Manager.Model.Admin.M_Stylist>();
        }
        /// <summary>
        /// 名设计师作品
        /// </summary>
        /// <returns></returns>
        private void BindOpus()
        {
            Manager.BLL.Admin.M_OpusBll bllOpus = new Manager.BLL.Admin.M_OpusBll();
            IList<Manager.Model.Admin.M_Opus> opuss = bllOpus.GetModelList("IsValid=1 Order By OpusID");
            ViewBag.OpusList = opuss.Take(5).ToList<Manager.Model.Admin.M_Opus>();
        }

        public ActionResult About()
        {
            return View();
        }
    }
}
